<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%user}}".
 *
 * @property int $id 自增用户id
 * @property string $username 用户名
 * @property string $password_hash 加密后密码
 * @property string|null $password_reset_token 找回密码token
 * @property string|null $verification_token verification token
 * @property string|null $email 用户邮箱
 * @property string $auth_key cookie验证auth_key
 * @property int $status 用户状态,10为正常
 * @property int $created_at 创建时间
 * @property int $updated_at 最后修改时间
 */
class User extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%user}}';
    }

    /**
     * {@inheritdoc}
     */
//    public function rules()
//    {
//        return [
//            [['username', 'password_hash', 'auth_key', 'created_at', 'updated_at'], 'required'],
//            [['status', 'created_at', 'updated_at'], 'integer'],
//            [['username', 'password_hash', 'password_reset_token', 'verification_token', 'email'], 'string', 'max' => 255],
//            [['auth_key'], 'string', 'max' => 32],
//            [['username'], 'unique'],
//            [['email'], 'unique'],
//            [['password_reset_token'], 'unique'],
//        ];
//    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => '自增用户id',
            'username' => '用户名',
            'password_hash' => '加密后密码',
            'password_reset_token' => '找回密码token',
            'verification_token' => 'verification token',
            'email' => '用户邮箱',
            'auth_key' => 'cookie验证auth_key',
            'status' => '用户状态,10为正常',
            'created_at' => '创建时间',
            'updated_at' => '最后修改时间',
        ];
    }

    /**
     * {@inheritdoc}
     * @return UserQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new UserQuery(get_called_class());
    }
}
